﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格设置为“100%”时获取表格的宽度</title>
    <script type="text/javascript">
        function getWidth(){
            let tbl = event.srcElement;
            tbl.innerText = tbl.offsetWidth + 'px';
        }
        
    </script>
</head>
<body>
<table width="100%"  height="100" border="1" cellpadding="0" cellspacing="0" >
    <tr>
        <td id="tbl1" onMouseOver="getWidth()">光标移过来</td> <td id="tbl2" onMouseOver="getWidth()">光标移过来</td>
    </tr>
</table>
</body>
</html>